package com.mars.ticket.controller;

import com.mars.ticket.request.ChatRecordRequest;
import com.mars.ticket.response.result.R;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

import java.util.Arrays;

import com.mars.ticket.entity.ChatRecord;
import com.mars.ticket.service.IChatRecordService;

/**
 * ChatRecord 控制层
 *
 * @Author wq
 * @Date 2021-03-15
 **/
@RestController
@RequestMapping("/chatRecord")
@AllArgsConstructor
public class ChatRecordController {

    private final IChatRecordService chatRecordService;

    /**
     * 发送消息
     *
     * @param request request
     * @return R
     */
    @PostMapping("/send")
    public R send(@RequestBody ChatRecordRequest request) {
        chatRecordService.send(request);
        return R.success();
    }

    @PostMapping("/reply")
    public R reply(@RequestBody ChatRecordRequest request) {
        chatRecordService.reply(request);
        return R.success();
    }

    /**
     * 接收消息
     *
     * @param request request
     * @return R
     */
    @PostMapping("admin/receive")
    public R receive(@RequestBody ChatRecordRequest request) {
        return R.success(chatRecordService.receive(request));
    }

    /**
     * 删除
     *
     * @param id id
     * @return R
     */
    @GetMapping("/delete")
    public R delete(Integer id) {
        chatRecordService.delete(id);
        return R.success();
    }


}